{% extends "admin/layout/admin.html" %}
{% block content %}
<div id="page-wrapper">
    <div class="row ">
        <div class="col-lg-12">
            <br/>
        </div>
    </div>
    <div class="row ">
        <div class="col-lg-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>用户组管理</strong>
                </div>
                <!-- /.panel-heading -->
                <div class="panel-body">

                    <div class="row ">
                        <div class="col-lg-12">
                            <div class="btn-group">
                                <button type="button" class="btn btn-success" data-toggle="modal" data-target=".add-resources-modal-lg">
                                    添加 
                                </button>    

                            </div>
                        </div>
                    </div>
                    <div class="row ">
                        <div class="col-lg-12">
                            <br/>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped table-bordered table-hover" >
                            <thead>
                                <tr>                                                                         
                                    <th>ID</th>                                            
                                    <th>用户组</th>                                    
                                    <th>描述</th>                                    
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                {%for row in list%}
                                <tr>                                    
                                    <td>{{row.id}}</td>                                            
                                    <td >
                                        {{row.name}}                                     
                                    </td>                                    
                                    <td>{{row.description}}</td>                                    
                                    <td><a href="{{url_to('auth/modifygroup',{'id':row.id} )}}" >修改</a>
                                        <a href="{{url_to('auth/deletegroup',{'id':row.id} )}}" onclick="return H_Confirm('确定删除吗');" >删除</a>
                                        
                                    </td>
                                </tr>                                            
                                {% else %}
                                <tr >
                                    <td colspan="4" align="center">暂无数据</td>                                            
                                </tr>    
                                {%endfor%}                                        
                            </tbody>
                        </table>

                    </div>
                </div>
                <!-- /#page-wrapper -->

                <!-- model -->
                <div class="modal fade add-resources-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
                    <div class="modal-dialog modal-lg">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                <h4 class="modal-title" id="myModalLabel">添加</h4>
                            </div>
                            <div class="modal-body">
                                <form role="form" id="addgroup" name="addgroup" method="post" action="{{url_to('auth/addgroup')}}" >
                                    
                                    <div class="form-group">
                                        <label for="description">用户组</label>
                                        <input type="text" class="form-control" name="name" id="name" placeholder="用户组名称">
                                    </div>
                                    
                                    <div class="form-group">
                                        <label for="description">描述</label>
                                        <input type="text" class="form-control" name="description" id="description" placeholder="描述">
                                    </div>
                                </form>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <input type="submit" class="btn btn-primary" value="保存" onclick="saveCategory();" />
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <script type="text/javascript" >
                function saveCategory(){
                    $.post("{{url_to('auth/addgroup')}}",$("#addgroup").serialize(),function(data){
//                        console.log(data);
                        location=location.href;
                    }); 
                }


            </script>
            {% endblock %}
            